Don't use container api on GtkStack
authorMatthias Clasen <mclasen@redhat.com>
Sun, 10 May 2020 01:01:24 +0000 (21:01 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 12 May 2020 02:21:39 +0000 (22:21 -0400)
gtk/gtkmenusectionbox.c
gtk/gtknotebook.c
gtk/gtkpopovermenu.c
gtk/gtktreepopover.c

index 6a36ae7510dbcdf398689f0b47680b7caaf98cb9..072b3287ca326ea13d2cca4dd247573562704140 100644 (file)
@@ -226,7 +226,7 @@ gtk_menu_section_box_remove_func (gint     position,
       stack = gtk_widget_get_ancestor (GTK_WIDGET (box->toplevel), GTK_TYPE_STACK);
       subbox = gtk_stack_get_child_by_name (GTK_STACK (stack), gtk_menu_tracker_item_get_label (item));
       if (subbox != NULL)
-        gtk_container_remove (GTK_CONTAINER (stack), subbox);
+        gtk_stack_remove (GTK_STACK (stack), subbox);
     }
 
   gtk_container_remove (GTK_CONTAINER (box->item_box),
@@ -476,18 +476,14 @@ update_popover_position_cb (GObject    *source,
 {
   GtkPopover *popover = GTK_POPOVER (source);
   GtkMenuSectionBox *box = GTK_MENU_SECTION_BOX (user_data);
+  GtkWidget *w;
 
   GtkPositionType new_pos = gtk_popover_get_position (popover);
 
-  GList *children = gtk_container_get_children (GTK_CONTAINER (gtk_widget_get_parent (GTK_WIDGET (box))));
-  GList *l;
-
-  for (l = children;
-       l != NULL;
-       l = l->next)
+  for (w = gtk_widget_get_first_child (gtk_widget_get_parent (GTK_WIDGET (box)));
+       w != NULL;
+       w = gtk_widget_get_next_sibling (w))
     {
-      GtkWidget *w = l->data;
-
       if (new_pos == GTK_POS_BOTTOM)
         gtk_widget_set_valign (w, GTK_ALIGN_START);
       else if (new_pos == GTK_POS_TOP)
@@ -495,8 +491,6 @@ update_popover_position_cb (GObject    *source,
       else
         gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
     }
-
-  g_list_free (children);
 }
 
 void
index eb5ac27d7d9a5e74cdb78c65e88919cf3e6d110a..d09f05aac699242dd85cca0d72061c90bec9f7da 100644 (file)
@@ -4004,7 +4004,7 @@ gtk_notebook_insert_notebook_page (GtkNotebook *notebook,
   if (notebook->menu)
     gtk_notebook_menu_item_create (notebook, page);
 
-  gtk_container_add (GTK_CONTAINER (notebook->stack_widget), page->child);
+  gtk_stack_add_named (GTK_STACK (notebook->stack_widget), page->child, NULL);
 
   if (page->tab_label)
     {
@@ -4221,7 +4221,7 @@ gtk_notebook_real_remove (GtkNotebook *notebook,
       gtk_widget_get_visible (GTK_WIDGET (notebook)))
     need_resize = TRUE;
 
-  gtk_container_remove (GTK_CONTAINER (notebook->stack_widget), page->child);
+  gtk_stack_remove (GTK_STACK (notebook->stack_widget), page->child);
 
   tab_label = page->tab_label;
   if (tab_label)
index cb920d028983057a4aaf0fc4ec4b691290dd13c0..718cfe1d58e195b4297ee96761feafdae506b23f 100644 (file)
@@ -685,7 +685,7 @@ gtk_popover_menu_set_menu_model (GtkPopoverMenu *popover,
 
       stack = gtk_popover_get_child (GTK_POPOVER (popover));
       while ((child = gtk_widget_get_first_child (stack)))
-        gtk_container_remove (GTK_CONTAINER (stack), child);
+        gtk_stack_remove (GTK_STACK (stack), child);
 
       if (model)
         gtk_menu_section_box_new_toplevel (popover, model, popover->flags);
index 636cb5180d6bda0ccb7ff79c80a02b7d440f8903..268462ab5c35cccee34fee33f67cae0254be05a2 100644 (file)
@@ -736,7 +736,7 @@ rebuild_menu (GtkTreePopover *popover)
 
   stack = gtk_popover_get_child (GTK_POPOVER (popover));
   while ((child = gtk_widget_get_first_child (stack)))
-    gtk_container_remove (GTK_CONTAINER (stack), child);
+    gtk_stack_remove (GTK_STACK (stack), child);
 
   if (popover->model)
     gtk_tree_popover_populate (popover);